package com.example.shopp_2301.pay

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope
import com.example.base.entity.ParamPay
import com.example.base.entity.PayResult
import com.example.base.mvvm.BaseModel
import com.example.base.mvvm.BaseViewModel
import kotlinx.coroutines.launch

class PayViewModel:BaseViewModel() {
    //返回值---订单支付
    val paySuccess = MutableLiveData<BaseModel<PayResult>>()
    val payFail = MutableLiveData<String>()
    fun pay(body:ParamPay){
        viewModelScope.launch {
            try {
                paySuccess.value = apiServer.pay(body)
            }catch (e:Exception){
                payFail.value = e.message
            }
        }
    }
}